﻿using ArbabTravelsERP.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ArbabTravelsERP.DAL;

namespace ArbabTravelsERP.Controllers
{
    public class SearchController : Controller
    {
        //
        // GET: /Search/
        public ActionResult Index()
        {
            return View();
        }

        private void GetAllMaster()
        {
            All_Master master = new All_Master();
            ViewData["GetCountryStateCity"] = master.GetCountryStateCity();
            ViewData["GetLocation"] = master.GetLocation();
            ViewData["GetLanguage"] = master.GetLanguage();
            ViewData["GetCompany"] = master.GetCompany();
            ViewData["GetDesignation"] = master.GetDesignation();
            ViewData["GetIndustry"] = master.GetIndustry();
            ViewData["GetEducation"] = master.GetEducation();
            ViewData["GetSpecialization"] = master.GetSpecialization();

        }

        [HttpGet]
        public ActionResult PortalSearch()
        {
            GetAllMaster();
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult PortalSearch(SearchModel search)
        {
            if (ModelState.IsValid)
            {
                return RedirectToAction("PortalSearch_Result", search);
            }

            GetAllMaster();
            return View();
        }


        [HttpGet]
        public ActionResult PortalSearch_Result(SearchModel search)
        {
            SearchModel portalsearch = new SearchModel();

            portalsearch.SearchGridDetails = SearchModel.GetSearchGridDetails(search);

            return View(portalsearch);
        }
    }
}